updating oE delete_routine

Automatic Resource Management

Euphoria objects are automatically garbage collected when they are no longer referenced anywhere. Euphoria also provides the ability to manage resources associated with euphoria objects. These resources could be open file handles, allocated memory, or other euphoria objects. There are two built-in routines for managing these external resources.

delete_routine

<built-in> function delete_routine( object x, integer rid ) 

associates a routine for cleaning up after a Euphoria object.

Comments:

delete_routine associates a euphoria object with a routine id meant to clean up any allocated resources. It always returns an atom (double) or a sequence, depending on what was passed (integers are promoted to atoms).

The routine specified by delete_routine should be a procedure that takes a single parameter, being the object to be cleaned up after. Objects are cleaned up under one of two circumstances. The first is if it's called as a parameter to delete. After the call, the association with the delete routine is removed.

The second way for the delete routine to be called is when its reference count is reduced to 0. Before its memory is freed, the delete routine is called. A default delete will be used if the cleanup parameter to one of the allocate routines is true.

delete_routine may be called multiple times for the same object. In this case, the routines are called in reverse order compared to how they were associated.

Not Categorized, Please Help

Search



Quick Links

User menu

Not signed in.

Misc Menu